@import "./_themes.scss";

//遍历主题map
@mixin themeify {
  @each $theme-name, $theme-map in $themes {
    //!global 把局部变量强升为全局变量
    $theme-map: $theme-map !global;
    //判断html的data-theme的属性值  #{}是sass的插值表达式
    //& sass嵌套里的父容器标识   @content是混合器插槽，像vue的slot
    [data-theme="#{'' + $theme-name}"] & {
      @content;
    }
  }
}

//声明一个根据Key获取颜色的function
@function themed($key) {
  @return map-get($theme-map, $key);
}

// 获取背景颜色
@mixin bg_color($bg_color) {
  @include themeify {
    background: themed($bg_color) !important;
  }
}

// 获取次级背景颜色
@mixin second_bg_color($second_bg_color) {
  @include themeify {
    background: themed($second_bg_color) !important;
  }
}

// 获取hover背景颜色
@mixin hover_bg_color($hover_bg_color) {
  @include themeify {
    background: themed($hover_bg_color) !important;
  }
}

// 获取border背景颜色
@mixin border_color($border_color) {
  @include themeify {
    border-color: themed($border_color) !important;
  }
}

// 获取字体颜色
@mixin text_color($text_color) {
  @include themeify {
    color: themed($text_color) !important;
  }
}

// 获取聚焦时的字体颜色
@mixin active_text_color($active_text_color) {
  @include themeify {
    color: themed($active_text_color) !important;
  }
}
